#pragma once
#include "DContactInfo.h"
#include "DSurfaceParameters.h"
#include "DContactGeom.h"
#include "DVector3.h"

namespace Skill
{
	namespace Ode
	{
		void DContactInfo::CollectManagedMemory()
		{
			_Geom = nullptr;
			_FDirection1 = nullptr;
			_Surface = nullptr;

		}
		int DContactInfo::SizeInBytes::get()
		{			
			return sizeof(dContact);
		}
		DSurfaceParameters^ DContactInfo::Surface::get()
		{
			if(_Surface)
				_Surface->_SetPointer(&_This->surface,false);
			else _Surface = gcnew DSurfaceParameters(&_This->surface);
			return _Surface;
		}
		void DContactInfo::Surface::set(DSurfaceParameters^ value)
		{
			_This->surface = *value->_This;
		}

		REF_PROP_DEFINITION_GET_FROM_VALUE(DContactInfo,geom,DContactGeom,Geom);		

		REF_PROP_DEFINITION_GET_FROM_REF(DContactInfo,fdir1,DVector3,FDirection1);
		void DContactInfo::FDirection1::set(DVector3^ value)
		{
			if(value)
			{
				_This->fdir1[0] = value->_This[0];
				_This->fdir1[1] = value->_This[1];
				_This->fdir1[2] = value->_This[2];
				_This->fdir1[3] = value->_This[3];
			}
		}

		void DContactInfoArray::CollectManagedMemory()
		{
			if(_Disposed)
				return;			
			for(int i=0;i<_Array->Length;i++)
			{
				_Array[i] = nullptr;
			}

			_Array = nullptr;
		}
		int DContactInfoArray::Length::get()
		{
			return _Array->Length;
		}
	}
}